<!-- src/components/CustomDialog.vue -->
<template>
  <div v-if="visible" class="dialog-overlay" @click.self="handleClose">
    <div class="dialog-container" :style="{ width: width, marginTop: top }">
      <div class="dialog-header">
        <slot name="title">
          <span class="dialog-title">购买记录</span>
        </slot>
        <button class="dialog-close" @click="handleClose">×</button>
      </div>
      <div class="dialog-body">
        <el-table v-loading="loading" :data="noticeList">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="彩票号" align="center" prop="lotteryNo" :show-overflow-tooltip="true" />
          <el-table-column label="日期" align="center" prop="lotteryDate"></el-table-column>
          <el-table-column label="用户名称" align="center" prop="userName" />
          <el-table-column prop="status" label="类型" width="80">
            <template slot-scope="scope">
              <el-tag>{{ scope.row.lotteryName }}</el-tag>
            </template>
          </el-table-column>

          <el-table-column label="倍数" align="center" prop="multiple">
            <template slot-scope="scope">
              <span v-if="scope.row.lotteryType === 1">
                <el-tag style="margin-right: 10px">直：{{ scope.row.multiple }}</el-tag>
                <el-tag type="success">组：{{ scope.row.buyGroup }}</el-tag>
              </span>
              <span v-else>
                <el-tag>倍{{ scope.row.multiple }}</el-tag></span
              >
            </template>
          </el-table-column>

       
        </el-table>
      </div>
      <div class="dialog-footer" v-if="$slots.footer">
        <slot name="footer"></slot>
      </div>
    </div>
  </div>
</template>

<script>
import { getByLottNoList } from "@/api/bussiness";

export default {
  name: "CustomDialog",
  data() {
    return {
        visible: false,
        fromJson: {},
        noticeList: [],
        loading:false
    };
  },
  props: {
    width: {
      type: String,
      default: "1000px",
    },
    top: {
      type: String,
      default: "15vh",
    },
    closeOnClickModal: {
      type: Boolean,
      default: true,
    },
  },
  methods: {
    open(form) {
      if (form.lotteryNo ) {
            this.fromJson = form;
            console.log(this.fromJson);
            this.getList({
                lotteryNo: form.lotteryNo,
                lotteryType: form.lotteryType,
            });
      }
      this.visible = true;
    },

    getList(params) {
      this.loading = true;
      getByLottNoList(params).then(response => {
        this.noticeList = response.data;
        this.total = response.total;
        this.loading = false;
      });
    },

    handleClose() {
      this.$emit("update:visible", false);
      this.$emit("close");
      this.visible = false;
    },
  },
  watch: {},
  beforeDestroy() {
    document.body.style.overflow = "";
  },
};
</script>

<style scoped>
p {
  margin: 0;
  margin-top: 10px;
}
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  animation: fadeIn 0.3s ease-out;
}

.dialog-container {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  animation: slideIn 0.3s ease-out;
}

.dialog-header {
  padding: 20px 20px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #ebeef5;
}

.dialog-title {
  font-size: 18px;
  font-weight: 600;
  color: #303133;
}

.dialog-close {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #909399;
  outline: none;
}

.dialog-close:hover {
  color: #409eff;
}

.dialog-body {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
  max-height: 60vh;
  min-height: 60vh;
 
}

.dialog-footer {
  padding: 15px 20px;
  text-align: right;
  border-top: 1px solid #ebeef5;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: translateY(-60px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .dialog-container {
    width: 90% !important;
    margin: 10vh auto !important;
  }
}
</style>
